<template>
	<view class="">
		<navbar title="充值订单" :back="true" color="#fff" leftIconColor="#fff"/>
		<view style="position: fixed;z-index: 20000;left: 0;width: 100%;padding-top: 20rpx;background-color: #3277fc;" :style="{top:`${topheight}px`}">
			<u-tabs :list="tabList" @click="changTab" :current="current" lineColor="#fff" :inactiveStyle="{color:'#fff'}" :activeStyle="{color:'#fff',fontWeight:'650'}"></u-tabs>
		</view>
		<view style="height: 100rpx;"></view>
		<u-empty v-if="orderList.length==0" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" text='您还没有充值记录哦~' marginTop='100'></u-empty>
		<view style="padding: 20rpx;" v-else>
			<view v-for="(item,index) in orderList" :key="index" class="item" >
				<view class="order">
					<view style="display:flex;justify-content: space-between;align-items: center;">
						<view class="text1">订单信息</view>
						<view class="text1" style="color: red;">{{item.paid==0?'待付款':item.paid==1?'已付款':''}}</view>
					</view>
					<view class="info">
						<view class="label u-flex u-row-left">
							<view class="text2">订单编号</view>
							<view>{{item.orderId}}</view>
							<view class="m-l-20">
								<u-button customStyle="height:40rpx;line-height:40rpx;font-size:20rpx;"
									@tap="copyText(item.orderId)">复制
								</u-button>
							</view>
						</view>
						<view class="label u-flex u-row-left">
							<view class="text2">创建时间</view>
							<view>{{item.addTime}}</view>
						</view>
						<view class="label u-flex u-row-left">
							<view class="text2">支付时间</view>
							<view>{{item.payTime?item.payTime:''}}</view>
						</view>
						<!-- <view class="label u-flex u-row-left">
							<view class="text2">赠送金</view>
							<view>{{(Number(item.totalPrice)+Number(item.givePrice))}}</view>
						</view>
						<view class="label u-flex u-row-left">
							<view class="text2">本金</view>
							<view>{{item.totalPrice}}</view>
						</view> -->
						<view class="label u-flex u-row-left">
							<view class="text2">支付金额</view>
							<view>{{item.payPrice}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import navbar from "@/components/baseNavbar.vue"
	import style from 'uni.scss'
	import {
		getorderReufnd
	} from '@/api/phoneBill.js'
	import {
		getorderList
	} from "@/api/make.js"
	export default{
		components:{
			navbar
		},
		data(){
			return{
				current:0,
				topheight:'',
				params:{
					refundMsg:'',
					oid:'',
				},
				show:false,
				customer: {
					color: '#0f0f0f',
					borderColor: '#999999',
					height: '50rpx'
				},
				style: {
					color: '#fff',
					backgroundColor: 'red',
					height: '50rpx'
				},
				orderList:[],
				loadend: false,
				loading: false,
				page: {
					page: 1,
					limit: 10,
					paid: '',
				},
				tabList: [{
						name: '全部',
						paid: '',
					}, {
						name: '待付款',
						paid: 0,
					}, {
						name: '已付款',
						paid: 1,
					}
				],
				
			}
		},
		onLoad(){
			this.topheight = uni.getMenuButtonBoundingClientRect().bottom+4
			this.resetList()
		},
		methods:{
			changTab(e){
				this.page.paid = e.paid
				this.resetList()
			},
			getId(id){
				console.log(id);
				this.show=true
				this.params.oid = id
			},
			resetList(callback) {
				this.page.page = 1;
				this.loading = false
				this.loadend = false
				this.orderList = []
				this.getList(callback)
			},
			getList(callback) {
				if (this.loadend || this.loading)
					return
				this.loading = true
				getorderList(this.page).then(res => {
					this.page.page++
					this.$set(this, 'orderList', this.orderList.concat(res.data.list))
					this.loading = false
					if (!res.data.hasNextPage)
						this.loadend = true
					if (callback != undefined) {
						callback()
					}
				}).catch(err => {
					this.loading = false
					this.loadend = true
					if (callback != undefined) {
						callback()
					}
				})
			},
			copyText(text){
			   uni.setClipboardData({
			     data:text,//要被复制的内容
			     success:()=>{//复制成功的回调函数
			       uni.showToast({//提示
			         title:'复制成功',
			   		 icon:'none'
			       })
			     }
			   });
			}
		}
	}
</script>
<style lang="scss">
	page {
		background-color: $uni-bg-color-grey;
	}
</style>
<style scoped lang="scss">
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.item {
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;

	}

	.text {
		font-size: 22rpx;
		color: #ff0000;
		line-height: 45rpx;

	}

	.avatar {
		border-radius: 50%;
		width: 100rpx;
		height: 100rpx;
	}

	.center {
		width: 500rpx;
		margin-left: 20rpx;
		font-size: 26rpx;
		line-height: 40rpx;
		color: #828282;
	}

	.text1 {
		font-size: 28rpx;
		line-height: 60rpx;
	}

	.order {
		margin-top: 10rpx;
	}

	.info {
		font-size: 24rpx;
		color: #828282;
	}

	.label {
		margin-bottom: 10rpx;
		align-items: center;
	}

	.text2 {
		width: 120rpx;
		text-align: right;
		margin-right: 40rpx;
	}

	.image {
		width: 120rpx;
		height: 120rpx;
		border-radius: 10rpx;
	}

	.cart {
		align-items: flex-start;
	}

	.text3 {
		font-size: 30rpx;
		font-weight: bold;
	}

	.text4 {
		font-size: 20rpx;
		background-color: #ffaa00;
		color: red;
		padding: 0 20rpx;
		line-height: 35rpx;
		border-radius: 15rpx;
		display: inline-block;
		margin-top: 10rpx;
	}

	.item-right {
		height: 120rpx;
		padding-left: 15rpx;
		width: 440rpx;
		font-size: 28rpx;
	}

	.item-end {
		height: 150rpx;
		width: 200rpx;
		font-size: 24rpx;
		text-align: right;
	}

	.price {
		line-height: 30rpx;
		font-size: 22rpx;
	}

	.right-item {
		width: 480rpx;
	}

	.list {
		padding: 20rpx;
	}

	.item-bottom {
		background-color: #ffaa00;
		height: 80rpx;
		border-radius: 80rpx 20rpx 0 0;
		padding-right: 20rpx;
	}
</style>
